<?php
#需要实现 只有平台管理员才能有权限搜索
namespace app\models;

use Yii;
use yii\base\Model;

class AdminSearch extends Admin
{

    public function rules()
    {
        return [
            ['username', 'default', 'value' => ''],
            ['username', 'string', 'message' => 'username必须是字符串',
                         'max' => 16, 'tooLong' => 'username最长16位'],
        ];
    }

    public function scenarios()
    {
        return Model::scenarios();
    }

    public function search($params)
    {
        $data['AdminSearch'] = $params;
        // P($data);

        $query = Admin::find();

        if (!($this->load($data) && $this->validate())) {
            return false;
        }
        // P($this);

        $query -> andFilterWhere(['like', 'username', $this->username]);

        return $query;
    }

    
}